<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue-2.4.0.js"></script>
    <script src="js/axios.min.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" placeholder="请输入Email" v-model="email">
        <input type="password" placeholder="请输入密码" v-model="password">
        <input type="button" value=" 登录 " @click="loginFn">
    </div>
</body>

<script>
    var vm = new Vue({
        el:'#app',
        data:{
            email:'',
            password:''
        },
        methods:{
            loginFn(){
                axios.get("http://localhost:8080/login",{
                    params: {
                        email: this.email,
                        password: this.password
                    }
                }).then(response => {
                    if (response.data.id == -1){
                        //登录失败，还在登录页，让用户重新登录
                        this.email = '';
                        this.password = '';
                        alert("用户名或密码错误");
                    }else{
                        //登录成功，进入问答页
                        //在代码中，切换浏览器地址栏中的地址
                        window.location.href = 'answer.html';
                    }
                    })
                }
            }

        });
</script>

</html>